<%@ include file="/en/jsp/static.jsp" %>
<%@ page import="linuxbox.bbs.logic.*" %>
<%@ page import="linuxbox.bbs.bean.*" %>
<%@ taglib uri="/linuxbox/common.tld" prefix="common" %>

<table width="100%" border=1 cellpadding=2 cellspacing=0 bgColor=#dddddd>
  <tr>
    <td bgcolor="#dddddd" height="20">
      <table width="100%" border=0 cellpadding=2 cellspacing=0 bgColor=#dddddd>
        <tr>
          <td nowrap>
            <p align="center"><b><font color=#d05000>BBS</font></b></p>
          </td>
          <td nowrap align=right>
            <a href="<%=BoxStatic.jspDir%>bbs/BbsNewList.jsp">More BBS...</a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
<%
  BbsManager bm = BbsManager.getInstance();
  int entriesPerPage = sec.getConfigInt("bbs", "HomePage", "Entries Per HomePage");

  ArrayList keys = bm.findNewList(entriesPerPage);

  Iterator it = keys.iterator(); 
  if ( it != null && it.hasNext() )
  {
    int count=0;
%>
  <tr>
    <td>
      <TABLE cellSpacing=1 cellPadding=0 width="100%" border=0 bgColor=#dddddd>
        <tr bgcolor="#7EC1F3">
          <th>Category</th>
          <th align="left">Subject</th>
        </tr>
<%

    BbsMsgKey key = null;
    BbsMsg msg = null;
    while (it.hasNext())
    {
      key = (BbsMsgKey)it.next();
      msg = bm.getBbsMsg(key);

      long lMsgID = msg.getID();
      long lTopicID = msg.getTopicID();
      String sAuthor = msg.getAuthor();
      java.sql.Date dtSubDate = msg.getSubDate();
      java.sql.Time tmSubTime = msg.getSubTime();
      String sSubject = msg.getSubject();
      int iCategory = msg.getCategory();
      String sCatName = msg.getCatName();

      String proptime = dtSubDate.toString() + " " + tmSubTime.toString();
      if (sSubject == null || sSubject.equals(""))
         sSubject = "(No Subject)";
%>
      <tr <% if ((count++ % 2) == 0) out.print("bgcolor=#f0f0f0"); %>>
        <td align="center" nowrap><%=sCatName%></td>
        <td nowrap>
          <a href="<%=BoxStatic.servletDir%>BbsViewAction?CAT_ID=<%=iCategory%>&MSG_ID=<%=lMsgID%>">
              <%=sSubject%> [ <%=sAuthor%> <%=proptime%> ]</a>
        </td>
      </tr>
<%
    }
%>
      </table>
    </td>
  </tr>
<%
  }
  else
  {
    out.print("<tr><td>No BBS entries</td></tr>");
  }
%>
</table>
